﻿//NorManager - OpenTTD Dedicated server manager
//Copyright (C) 2014 Tomáš Bosek

//This program is free software: you can redistribute it and/or modify
//it under the terms of the GNU General Public License as published by
//the Free Software Foundation, either version 3 of the License.

//This program is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//GNU General Public License for more details.

//You should have received a copy of the GNU General Public License
//along with this program.  If not, see <http://www.gnu.org/licenses/>.
using System;
using System.Text;
using CommandLine;
using CommandLine.Text;
using CommandLine.Parsing;

namespace NorManager
{
    class StartArguments
    {
        private string executable;
        [Option('e', "exec", HelpText = "Server executable path.")]
        public string Executable { get { return executable; } set { executable = value; } }

        private string config;
        [Option('c', "config", HelpText = "Server config path.")]
        public string Config { get { return config; } set { config = value; } }

        private bool autoload;
        [Option('a', HelpText = "If set, server automatically loads last save. Looks for saves in config path(or directory, where is this program located).")]
        public bool Autoload { get { return autoload; } set { autoload = value; } }

        [HelpOption]
        public void GetUsage()
        {
            var help = new HelpText
            {
                //Please, do not remove this line.
                Heading = new HeadingInfo("NorManager v"+Logger.Version+" for OpenTTD dedicated server.\n(Nor means Noraxus -> name of my good friend and owner of our OpenTTD server.)"),
                Copyright = new CopyrightInfo("Tomáš Bosek", 2014),
                AdditionalNewLineAfterOption = true,
                AddDashesToOption = true
            };
            help.AddPreOptionsLine("Usage: -x argument | --x argument | -xargument");
            help.AddOptions(this);

            Console.WriteLine(help.ToString());
            if(Environment.OSVersion.ToString().Contains("Windows"))
                Logger.Instance.Log("ATTENTION: It's important to kill any instance of openttd.exe before first launch of this program!", ConsoleColor.Red);
        }
    }
}
